package com.zeroext.action.common;

import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;

import javax.servlet.http.HttpServletResponse;

@SuppressWarnings("serial")
public class OutZeroextAction extends BaseAction {
    public String getStringData(){
        try{
            String url = this.getRequest().getParameter("url");
            URL uri = new URL(url);
            HttpURLConnection con = (HttpURLConnection) uri.openConnection();
            con.connect();
            InputStream is = con.getInputStream();
            HttpServletResponse res = this.getResponse();
            OutputStream os = res.getOutputStream();
            byte[] bf = new byte[1024];
            int length = is.read(bf);
            while (length != -1) {
                os.write(bf, 0, length);
                length = is.read(bf);
            }
            is.close();
        }catch(Exception e){
            System.out.println(e.getMessage());
        }
        return null;
    }
}
